<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Project 02</title>

<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/mainstyle.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/calendar.css" />
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery-1.7.1.js"></script>

<!-- credit jqueryUI -->

<link rel="stylesheet" href="<?php echo base_url(); ?>development-bundle/themes/violet/jquery.ui.all.css" />
<script src="<?php echo base_url(); ?>development-bundle/external/jquery.bgiframe-2.1.2.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.core.js"></script>

<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.widget.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.mouse.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.button.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.draggable.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.position.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.resizable.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.datepicker.js"></script>

<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.dialog.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.ui.tabs.js"></script>
<script src="<?php echo base_url(); ?>development-bundle/ui/jquery.effects.core.js"></script>
<link rel="stylesheet" href="<?php echo base_url(); ?>development-bundle/demos/demos.css"/>

<!-- End jqueryUI -->

<style>
	input.text { margin-bottom:12px; width:95%; padding: .4em; }
	fieldset { padding:0; border:0; margin-top:25px; }
	h1 { font-size: 1.2em; margin: .6em 0; }
	div#users-contain { width: 350px; margin: 20px 0; }
	div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
	div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
	#login{ font-size:14px; padding-right: 10px;}
	#login:hover{ cursor: pointer; }
	#search_form{ padding-left: 40px; padding-top: 30px; }
	#search_btn_span{ padding-left: 80px; }
</style>

<script type="text/javascript">
	$(document).ready(function(){

		//set login form
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
		
		$( "#dialog-form" ).dialog({
			autoOpen: false,
			height: 250,
			width: 300,
			modal: true,
			resizable: false,
			buttons: {
				"Login": function() {
					$.post("<?=base_url()?>member/validate_login",{
						username: $("#username").val(),
						password: $("#password").val()},
							function(result){
								if(result=='Y'){
									$( this ).dialog( "close" );
									window.location="<?=base_url()?>main/index";
								}
								else{
									$("#login_err").show();
								}
							}
					);
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
				$('#username').val("");
				$('#password').val("");
			}
			});
	
			$( "#login" ).click(function() {
					$( "#dialog-form" ).dialog( "open" );
			});

			$("#login_err").hide();
			//end set login form
		
	});
</script>

</head>

<body>

	<div class="middle">
	
		<!-- Welcome User or login -->
		<div class = "uperbar" align="right">
			<?php 
				if(isset($this->session->userdata['name'])){
					?><label>
						ยินดีต้อนรับ&nbsp;&nbsp;
						<?=$this->session->userdata('name')?>&nbsp;
						<?=$this->session->userdata('surname')?>&nbsp;&nbsp;
						<a href="<?=base_url()?>member/logout">log out</a>&nbsp;&nbsp;
					</label>&nbsp;&nbsp;<?php
				} 
				else{
					?><label id="login">login</label>&nbsp;&nbsp;<?php
				}
			?>
			
		</div>
		<!-- End Welcome User or login -->
		
		<div class="head"></div>
		<div class = "manubar">
			<div class="top-nav">
				<ul>
				<?php 
					//check session for list menu
					if($this->session->userdata('type')!=null){
						//menu for admin
						if($this->session->userdata('type')==0 || $this->session->userdata('type')==1){
				?>
							<li><a href="<?php echo base_url() .'approve/index' ?>">Approve</a></li>
							<li><a href="<?php echo base_url() .'main/index' ?>">Home</a></li>
			                <li><a href="#">statistic</a></li>
			                <li><a href="<?php echo base_url() .'room/index'?>">Room</a></li>
			                <li><a href="<?php echo base_url() .'history/index'?>">History</a></li>
			                <li><a href="<?php echo base_url() .'contact/index'?>">Contact Us</a></li>
				<?php 
						}
						else{
				?>
							<li><a href="<?php echo base_url() .'approve/index' ?>">Approve</a></li>
							<li><a href="<?php echo base_url() .'main/index' ?>">Home</a></li>
			                <li><a href="#">statistic</a></li>
			                <li><a href="<?php echo base_url() .'room/index'?>">Room</a></li>
			                <li><a href="<?php echo base_url() .'history/index'?>">History</a></li>
			                <li><a href="<?php echo base_url() .'contact/index'?>">Contact Us</a></li>
				<?php	
						}
					}
					//for not login
					else{
				?>
						<li><a href="<?php echo base_url() .'main/index' ?>">Home</a></li>
			            <li><a href="#">statistic</a></li>
			            <li><a href="<?php echo base_url() .'contact/index'?>">Contact Us</a></li>
				<?php
					}
				?>
	                
					
				</ul>
			</div>	
		</div>
		
		<div class="content">
		
			
			<!-- login form -->
			<div id="dialog-form" title="Login">
				<form>
				<fieldset>
					<label for="name">Username</label>
					<input type="text" name="username" id="username" class="text ui-widget-content ui-corner-all" />
					<label for="password">Password</label>
					<input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
					<span id="login_err" style="color:red;padding-left:100px;">Login ผิดพลาด</span>
				</fieldset>
				</form>
			</div>
			<!-- end login form -->